// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
// import Vue from 'vue'
import App from './App'
import router from './router'
// import axios from 'axios'
import BaseCss from './css/base.css'//公用CSS


Vue.prototype.$ajax = axios
Vue.prototype.HOME = '/api'


//引入基本模板
let echarts = require('echarts/lib/echarts')
 
// 引入折线图等组件
require('echarts/lib/chart/line');

// 引入提示框和title组件，图例
require('echarts/lib/component/tooltip')
require('echarts/lib/component/title')
require('echarts/lib/component/legend')
// require('echarts/lib/component/legendScroll')

Vue.prototype.$echarts = echarts

import 'lib-flexible/flexible' // px自动转rem
import 'lib-flexible'

//按需引入element
// import 'element-ui/lib/theme-chalk/index.css' 
import element from './element'
Vue.use(element)
  
Vue.config.productionTip = false;

Vue.filter('DatHandle', function (value) {
	if(value == null){
		value = 0
	}
	var NumPart =  Number(value) | 0;
	var NumFormat = NumPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
	
	return NumFormat
});

Vue.prototype.Cookie = {// 封装原生cookie
	get:function(name){
			// 获取所有
			var cookies = document.cookie;
			// 转成数组
			cookies = cookies.split('; ');//['goodslist=[]','your=lemon']
			var res = '';
			for(var i=0;i<cookies.length;i++){
				// 拆分cookieName和cookieValue
				var arr = cookies[i].split('=');
				if(arr[0] === name){
					res = arr[1];
					break;
				}
			}
			return res;
	},
	set:function(name,value,param){
			var cookie = name + '=' + value;
			if(param){
					if(param.expires){
							cookie += ';expires='+param.expires.toUTCString();
					}
					if(param.path){
							cookie += ';path=' + param.path;
					}
					if(param.domain){
							cookie += ';domain=' + param.domain;
					}
					if(param.secure){
							cookie += ';secure'
					}
			}		
			document.cookie = cookie;
	},
	remove:function(name,path){
			// 原理：设置过期时间达到删除效果
			var now = new Date();
			now.setDate(now.getDate()-1);
			this.set(name,null,{expires:now,path:path});
	}

};

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router, 
  components: { App },
  template: '<App/>'
})
